<template>
    <el-card shadow="hover" :body-style="{padding:'20px'}">
        <el-form :inline="true">
            <el-form-item label="一级分类">
                <el-select v-model="categoryStore.c1Id" @change="c1Handle" :disabled="scene!=0">
                    <el-option :key="c1.id" :label="c1.name" :value="c1.id" v-for="(c1,index) in categoryStore.c1List">
                    </el-option>
                </el-select>
            </el-form-item>

            <el-form-item label="二级分类">
                <el-select v-model="categoryStore.c2Id" @change="c2Handle" :disabled="scene!=0">
                    <el-option :key="c2.id" :label="c2.name" :value="c2.id" v-for="(c2,index) in categoryStore.c2List">
                    </el-option>
                </el-select>
            </el-form-item>

            <el-form-item label="三级分类">
                <el-select v-model="categoryStore.c3Id" :disabled="scene!=0">
                    <el-option :label="c3.name" :value="c3.id" v-for="(c3,index) in categoryStore.c3List" :key="c3.id">
                    </el-option>
                </el-select>
            </el-form-item>

        </el-form>
    </el-card>


</template>

<script setup lang="ts">

import { ref, onMounted } from 'vue';
//获取仓库
import useCategoryStore from '../../stores/category';
let categoryStore = useCategoryStore();

//组件挂载完毕
onMounted(() => {
    //通知pinia仓库发送请求，获取一级分类的数据
    categoryStore.getC1List();
});

//一级分类下拉菜单的change事件，获取二级分类数据
const c1Handle = () => {
    categoryStore.getC2List();
};
//二级分类下拉菜单的change事件，获取三级分类数据、
const c2Handle = () => {
    categoryStore.getC3List();
};
//接收父组件传递过来的数据，限制三级分类
defineProps(["scene"])
</script>

<style scoped>

</style>